# 1列表
name1 = '小明'
name2 = '小明'
name3 = '小李'

# 声明 []
name_list = ['小明', '小红', '小李']
# 追加
name_list.append('小青')
print(name_list)
name_list.pop()
print(name_list)
# 查找和索引  从0开始编号代表每一项   注意中括号含义不同
print(name_list[2])
# 迭代，数据处理
name_list_new = []
name_list = ['小明', '小红', '小李']
for name in name_list:
    name = '我叫' + name
    name_list_new.append(name)
print(name_list_new)
# 列表生成式,简写
print([name for name in name_list])
# 切片
print(name_list[0:2])


# 字典 dict   map 对象
# 声明 {key:value, } 键值对
# 比较 列表装一组类似的事务，字典一个事务的不同属性和值
student = {'name': '小明', 'age': 13, 'gender': '男'}
# 查找
print(student['age'])
# 修改
student['age'] = 15
print(student)
# 迭代
for i in student.values():
    print(i)

# 元组tuple
# 跟列表相似但不能修改，常用与配置声明
gender_choice = ('男', '女')
# gender_choice[0] = 'female'


# 嵌套
students = [
    {'name': '小明', 'age': 13, 'gender': '男'},
    {'name': '小红', 'age': 11, 'gender': '女'},
    {'name': '小李', 'age': 12, 'gender': '男'},
]
for stu in students:
    print(stu['name'])
    # stu['age'] = '10'
    # students[0]['age'] = 10
print(students)

for k in range(0, len(students)):
    stu = students[k]
# 枚举
for index,stu in enumerate(students):
    print(index, stu)
    students[index]['age'] = 10

    print(students[index])
print(students)